# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :jwt_auth.py
# @Time      :2022/6/9 0009 14:27
# @Author    :何胜利
from flask import request, g
from common.utils.jwt_util import create_token


def jwt_authentication():
    g.user_id = None
    g.is_refresh = False

    token = request.headers.get('Authorization')
    print("获取的前端token", token)
    if token:
        payload = create_token(token)
        if payload:
            print("校验前端的token结果", payload)
            g.user_id = payload.get("user_id", None)
            g.is_refresh = payload.get("is_refresh", False)
